﻿using System;
using System.Diagnostics;

namespace SharpTrainer
{
    public class PerformanceManager
    {
        private string moduleName;

        private Stopwatch startTime;
        private string endTime;
        private ITimeDevice timeDevice;

        public PerformanceManager(string moduleName, ITimeDevice timeDevice)
        {
            this.moduleName = moduleName;
            this.timeDevice = timeDevice;
        }

        public void Start()
        {
            startTime = Stopwatch.StartNew();
        }

        public void Stop()
        {
            endTime = startTime.Elapsed.ToString();
        }

        public void PrintTime()
        {
            timeDevice.Print(moduleName, endTime);
        }
    }
}
